/*
 * @Description: 键盘keyCode映射
 * @Author: wws1993
 * @Date: 2020-11-27 10:45:58
 * @LastEditTime: 2020-11-30 16:37:19
 * @LastEditors: wws1993
 * @FilePath: \todoManager\src\lib\KeyboradCode.ts
 */

interface IKeyboradCode {
  [l: string]: number;
  backSpace: number;
  tab: number;
  enter: number;
  capsLock: number;
  space: number;
  left: number;
  up: number;
  right: number;
  down: number;
}

const KeyboradCodes: IKeyboradCode = {
  backSpace: 8,
  tab: 9,
  enter: 13,
  capsLock: 20,
  space: 32,
  left: 37,
  up: 38,
  right: 39,
  down: 40,
};

let lib = 'abcdefghijklmnopqrstuvwxyz'.split('');
lib.map((k, idx) => {
  KeyboradCodes[k] = 65 + idx;
  KeyboradCodes[k.toUpperCase()] = 65 + idx;
});

lib = '0123456789'.split('');
lib.map((k, idx) => {
  KeyboradCodes[k] = 48 + idx;
});

lib = '1,2,3,4,5,6,7,8,9,10,11,12'.split(',');
lib.map((k, idx) => {
  KeyboradCodes['F' + k] = 112 + idx;
});

export default KeyboradCodes;
